Skip to content

fix(emotion): use the cooked template value for css escapes - #175

Open
tlq5l wants to merge 1 commit into
rolldown:mainfrom
tlq5l:fix/emotion-cooked-template-165
Open

tlq5l wants to merge 1 commit into
rolldown:mainfrom
tlq5l:fix/emotion-cooked-template-165

Conversation

@tlq5l

@tlq5l tlq5l commented Nov 23, 2026

Copy link
Copy Markdown

The emotion plugin turned \\f007 in a css template into a form feed followed by 007, and left a stray backslash in \\\".

It decoded each quasi from value.raw with unescapeTemplateRaw, which runs one .replace per escape and handles \\ last. This uses the parser's value.cooked instead, which is what emotion's Babel plugin reads and what css receives at runtime without a plugin. As in those two, escapes are now read the way JavaScript reads them, so a CSS escape such as \e900 needs a double backslash (\\e900); with a single backslash it becomes e900. unescapeTemplateRaw is still used when there is no cooked value (an invalid escape in a tagged template). The issue's input is added as the issue-165 fixture.

fixes #165

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plugin-emotion] escape sequences in css template literals are decoded incorrectly (\\f007 becomes a form feed)

1 participant